#include "WIFI_Connection.h"
#include "wifi_http_client.h"

void wifi_test_task(void *params)
{
    // 等待wifi连接成功之后释放锁
    if (xSemaphoreTake(wifiConnectionSemaphore, portMAX_DELAY) == pdTRUE)
    {
        // Execute wifi_test_http_client_init after wifi_connection is done
        wifi_test_http_client_init(2, (char *[]){
                                          "wifi_http_test",
                                          "ai-thinker.com"});
    }
}
int main(void)
{
    board_init();
    tcpip_init(NULL, NULL);
    wifi_start_firmware_task();
    // 更换成你们自己的WIFI密码
    WiFiTaskParameters wifiTaskParams = {"ywlim22@unifi", "v6%+Nt8M"}; // wifi ssid and password
    wifiConnectionSemaphore = xSemaphoreCreateBinary();
    // 连接wifi
    xTaskCreate(wifi_connection, (char *)"heap", 1024, &wifiTaskParams, 1, NULL);
    // 创建发送请求的任务
    xTaskCreate(wifi_test_task, (char *)"wifiTest", 1024, NULL, 2, NULL);
    // 开启任务调度
    vTaskStartScheduler();

    while (1)
    {
    }
}